package com.example.tencentdemo.service.Impl;

import com.example.tencentdemo.DTO.adminMsg;
import com.example.tencentdemo.Mapper.admin_messageMapper;
import com.example.tencentdemo.entity.admin_message;
import com.example.tencentdemo.entity.group_message;
import com.example.tencentdemo.Mapper.group_messageMapper;
import com.example.tencentdemo.service.MessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.sql.Timestamp;
import java.util.Date;
import java.util.List;

@Service
public class MessageImpl implements MessageService {
    @Autowired
    private group_messageMapper group_messageMapper;
    @Autowired
    private admin_messageMapper admin_messageMapper;
    @Override
    public List<group_message> queryByGid(String group_id) {
        return group_messageMapper.queryByGid(group_id);
    }

    @Override
    public int insertMessage(group_message group_message) {
        group_message.setSend_time(new Timestamp(new Date().getTime()));
        group_messageMapper.insertMessage(group_message);
        return 1;
    }

    @Override
    public List<admin_message> getChatRecords(adminMsg adminMsg) {
        return admin_messageMapper.getChatRecords(adminMsg);
    }


    @Override
    public int insertAdmin_Message(admin_message admin_message) {
        admin_message.setSend_time(new Timestamp(new Date().getTime()));
        admin_messageMapper.insertMessage(admin_message);
        return 1;
    }
}
